package com.five.monkey.feign.consumer.client.fallback;

import com.five.monkey.feign.consumer.client.UserFeignClient;
import com.five.monkey.vo.CommonVo;
import com.five.monkey.vo.PageVo;
import com.five.monkey.vo.UserVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author 狻猊
 * @date 2021/8/10 下午5:45
 */
@Component
public class UserFeignClientFallback implements UserFeignClient {

    private static Logger logger = LoggerFactory.getLogger(UserFeignClientFallback.class);

    @Override
    public CommonVo<UserVo> login(String name, String password) {
        logger.error("/provider/user/login请求异常。name={},password={}", name, password);
        return CommonVo.exception(1, "/provider/user/login请求异常");
    }

    @Override
    public CommonVo<UserVo> findById(Long id) {
        logger.error("/provider/user/find/by/{id}请求异常。id={}", id);
        return CommonVo.exception(1, "/provider/user/find/by/{id}请求异常");
    }

    @Override
    public CommonVo<UserVo> saveToElasticsearch(UserVo userVo) {
        logger.error("/save/to/elasticsearch请求异常。userVo={}", userVo);
        return CommonVo.exception(1, "/save/to/elasticsearch请求异常");
    }

    @Override
    public CommonVo<UserVo> findByIdFromElasticsearch(Long id) {
        logger.error("/find/by/{id}/elasticsearch请求异常。id={}", id);
        return CommonVo.exception(1, "/find/by/{id}/elasticsearch请求异常");
    }

    @Override
    public CommonVo<Boolean> deleteByIdFromElasticsearch(Long id) {
        logger.error("/delete/by/{id}/elasticsearch请求异常。id={}", id);
        return CommonVo.exception(1, "/delete/by/{id}/elasticsearch请求异常");
    }

    @Override
    public CommonVo<List<UserVo>> findAllFromElasticsearch() {
        logger.error("/find/all/elasticsearch请求异常。");
        return CommonVo.exception(1, "/find/all/elasticsearch请求异常");
    }

    @Override
    public CommonVo<PageVo<UserVo>> pageByStatusFromElasticsearch(Integer status, int page, int size) {
        logger.error("/page/by/{status}/elasticsearch请求异常。status={}, page={}, size={}", status, page, size);
        return CommonVo.exception(1, "/page/by/{status}/elasticsearch请求异常");
    }

    @Override
    public CommonVo<List<UserVo>> listByStatusFromElasticsearch(Integer status) {
        logger.error("/list/by/{status}/elasticsearch请求异常。status={}", status);
        return CommonVo.exception(1, "/list/by/{status}/elasticsearch请求异常");
    }
}
